import store from 'store'
import { postLoginWxMinSimpleAPI } from '@/api/profile'

export default {
  // 命名空间
  namespaced: true,
  state: {
    profile: null
  },
  getters: {},
  mutations: {
    setProfile (state, profile) {
      // console.log(profile)
      state.profile = profile
    }
  },
  actions: {
    async postLoginWxMinSimple (store, profile) {
      const res = await postLoginWxMinSimpleAPI(profile)
      // console.log(res)
      store.commit('setProfile', res.result)
      uni.showToast({
        title: '登陆成功',
        icon: 'success'
      })
      setTimeout(() => {
        uni.navigateBack()
      }, 1500)
    }
  }
}
